package com.bawei.day0129.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SPUtils {
    private static SharedPreferences sp;

    public synchronized static void init(Context context){
        if (sp==null){
            sp = context.getSharedPreferences("sp", Context.MODE_PRIVATE);
        }
    }

    public static String getString(String key,String value){
        return sp.getString(key,value);
    }

    public static void putString(String key,String value){
        sp.edit().putString(key, value).commit();
    }

    public static int getInt(String key,int value){
        return sp.getInt(key,value);
    }

    public static void putInt(String key,int value){
        sp.edit().putInt(key, value).commit();
    }

    public static boolean getboolean(String key,boolean value){
        return sp.getBoolean(key, value);
    }

    public static void putboolean(String key,boolean value){
        sp.edit().putBoolean(key, value).commit();
    }
    public static void CleanString(String key ){
        sp.edit().remove(key).commit();
    }
    public static void clear(){
        sp.edit().clear().commit();
    }
}
